# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Budget do
  @moduledoc """
  A budget is a plan that describes what you expect to spend on Cloud projects, plus the rules to execute as spend is tracked against that plan, (for example, send an alert when 90% of the target spend is met). The budget time period is configurable, with options such as month (default), quarter, year, or custom time period.

  ## Attributes

  *   `allUpdatesRule` (*type:* `GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1AllUpdatesRule.t`, *default:* `nil`) - Optional. Rules to apply to notifications sent based on budget spend and thresholds.
  *   `amount` (*type:* `GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1BudgetAmount.t`, *default:* `nil`) - Required. Budgeted amount.
  *   `budgetFilter` (*type:* `GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Filter.t`, *default:* `nil`) - Optional. Filters that define which resources are used to compute the actual spend against the budget amount, such as projects, services, and the budget's time period, as well as other filters.
  *   `displayName` (*type:* `String.t`, *default:* `nil`) - User data for display name in UI. Validation: <= 60 chars.
  *   `etag` (*type:* `String.t`, *default:* `nil`) - Optional. Etag to validate that the object is unchanged for a read-modify-write operation. An empty etag will cause an update to overwrite other changes.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. Resource name of the budget. The resource name implies the scope of a budget. Values are of the form `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
  *   `ownershipScope` (*type:* `String.t`, *default:* `nil`) - 
  *   `thresholdRules` (*type:* `list(GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1ThresholdRule.t)`, *default:* `nil`) - Optional. Rules that trigger alerts (notifications of thresholds being crossed) when spend exceeds the specified percentages of the budget. Optional for `pubsubTopic` notifications. Required if using email notifications.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :allUpdatesRule =>
            GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1AllUpdatesRule.t()
            | nil,
          :amount =>
            GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1BudgetAmount.t()
            | nil,
          :budgetFilter =>
            GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Filter.t()
            | nil,
          :displayName => String.t() | nil,
          :etag => String.t() | nil,
          :name => String.t() | nil,
          :ownershipScope => String.t() | nil,
          :thresholdRules =>
            list(
              GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1ThresholdRule.t()
            )
            | nil
        }

  field(:allUpdatesRule,
    as: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1AllUpdatesRule
  )

  field(:amount,
    as: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1BudgetAmount
  )

  field(:budgetFilter,
    as: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Filter
  )

  field(:displayName)
  field(:etag)
  field(:name)
  field(:ownershipScope)

  field(:thresholdRules,
    as: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1ThresholdRule,
    type: :list
  )
end

defimpl Poison.Decoder,
  for: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Budget do
  def decode(value, options) do
    GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Budget.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.BillingBudgets.V1beta1.Model.GoogleCloudBillingBudgetsV1beta1Budget do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
